use thiserror::Error;
use tls_codec;

use super::device::DeviceIdent;

#[derive(Debug, Error)]
pub enum Error {
    #[error("ident malformed")]
    MalformedIdent,

    #[error("tried to construct equiv from unrelated DIRs")]
    EquivUnrelated(DeviceIdent, DeviceIdent),

    #[error("tried to construct equiv from two the same DIR packages")]
    EquivSameDir,

    #[error("tried to construct equiv from DIRs with different seqnos")]
    EquivDifferentSeqnos,

    /// Only used when parsing directly from a vec.
    #[error("device ident wrong length (got {0})")]
    DeviceIdentWrongLen(usize),

    #[error("key package verify: {0}")]
    MlsParseKeyPackage(#[from] openmls::key_packages::errors::KeyPackageVerifyError),

    #[error("mls: {0}")]
    MlsLibrary(#[from] openmls::error::LibraryError),

    #[error("tls codec: {0}")]
    TlsCodec(#[from] tls_codec::Error),
}
